package com.skynet.supervision.utils.functional;

import java.util.function.Supplier;

@FunctionalInterface
public interface ThrowableSupplier<T, E extends Throwable> {
    T get() throws E;

    default Supplier<T> toSupplier() {
        return () -> {
            try {
                return ThrowableSupplier.this.get();
            } catch (Throwable e) {
                FuncUtils.uncheckedThrow(e);
            }
            throw new RuntimeException("unreachable");
        };
    }
}
